public class hw8 {
    public static void main(String[] args) {
        // 1/n sum

        int n = 2;
        double sum = 1 ;
        double i = -1;
        while (n <= 100) {
            double tmp = i/n;
            sum += tmp;
            i = -i;
            n++;
        }
        System.out.println("1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 值为："+sum);
    }

}
